<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
  <head>
    <link href="<s:url value="/resources"/>/css/style_new.css" rel="stylesheet" type="text/css" />
    <link href="<s:url value="/resources"/>/css/main_new.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script>    
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.alerts.js"></script>
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/jquery.alerts.css" />
    <style>
		html, body {
			margin: 0;			 
			padding: 0;
		    font-size: 85%;
		}
	</style>
  </head>
  
  <script type="text/javascript"> 
   $(function(){ 
	    $( "#datepicker" ).datepicker({dateFormat:'yy-mm'});
	    $( "#datepicker1" ).datepicker({dateFormat:'yy-mm'});
	    loadTab();
  });
  
  
  function loadTab(){
    //加载列表
    $("#myTab").jqGrid({      
		    url:'<s:url value="/hwjs"/>/findHwfyGrid',   
		    datatype: 'json',
		    mtype: 'post',         
		   	colNames:['编辑','铁路计划号','买受人','发货单位','收货单位','发站','到站','发运吨数','发运车数','发运日期','品名'],
		   	colModel:[
		      	{name:'caoz',index:'sysid',width:60,align:"center"}, 
		   		{name:'pizhh',index:'pizhh',width:120},
		   		{name:'maishr',index:'maishr'},
		   		{name:'fahdw',index:'fahdw'},		
		   		{name:'shouhdw',index:'shouhdw',width:50},		
		   		{name:'fazh',index:'fazh'}, 
		   		{name:'daozh',index:'daozh',width:50},
		   		{name:'faydsh',index:'faydsh',width:50},
		   		{name:'faychsh',index:'faychsh',width:50},		
		   		{name:'fayrq',index:'fayrq',width:50},	
		   		{name:'pinm',index:'pinm',width:50}
		   	],
		    jsonReader: {
		           repeatitems : false, 
		           id: 'sysid'
		         },   
		    height:250, 
		    width: 1070, 	
		   	rowNum:10,
		   	rowList:[10,30,50],     	
		   	pager: '#pager', 
		   	rownumbers: true,   	 
		    viewrecords: true,
		    multiselect : true,
		    sortorder: 'desc', 
		    caption: "发运单",
			gridComplete:function()
				{ //在此事件中循环为每一行添加修改和删除链接 	
					var ids=$("#myTab").jqGrid('getDataIDs'); 
					//alert(ids);
					for(var j=0; j<ids.length; j++)
					{		
					     id=ids[j];		    
						 caoz="<a href='#' style='color:#f60' onclick='chak("+ id +")'>查看</a>&nbsp;|&nbsp;" +
						          "<a href='#' style='color:#f60' onclick='bianj("+ id +");'>编辑</a>&nbsp;";
						 $("#myTab").jqGrid('setRowData',id, { caoz: caoz }); 
						
					}
				}	
		  });  		
         }
    
       //批量删除
		function batchremove() {	
			var sysid = $("#myTab").jqGrid('getGridParam','selarrrow');
			if (sysid.length == 0)
			{
			    jAlert('请至少选择一条记录','提示');
			}
			else
			{
			var url = "<s:url value="/hwjs"/>/removeFydBatch?sysid="+sysid;
			$( "#dialog-confirm" ).dialog({
					resizable: false,
					height:140,
					modal: true,
					buttons: {
						"确认": function() {
							$.post(url, function(data) {
								var obj = eval('(' + data + ')');
								if(obj.success==true){
								        location.href ="<s:url value="/hwjs"/>/directFyddb";
								        //loadTab();
								        /*  $("#myTab").jqGrid('setGridParam',{   
						                          url:'<s:url value="/hwjs"/>//directFyddb',
												  mtype:'post',
												  page:1
							              }).trigger("reloadGrid");   */
								 }else{
								         alert(obj.msg);
								       }
		                   });
		                   $( this ).dialog( "close" ); 
						},
						"返回": function() {
							$( this ).dialog( "close" );
						}
					}
				});
			}
		}
		
  
	// 查询
	function search(){ 
	  var formdata = $("#form1").serialize(); 
	  $("#myTab").jqGrid('setGridParam',{url:'<s:url value="/hwjs"/>/findHwfyGrid?'+ formdata,mtype:'post', page:1}).trigger("reloadGrid");  
	}

    
	
	//查看
	function chak(id) { 
	    window.location.href='<s:url value="/hwjs"/>/chakFyd?sysid='+ id;
	}
	
	
	//编辑
	function bianj(id) { //单击链接执行编辑操作
	/* //alert(id); 
	if(id.id!=undefined){
	window.location.href='<s:url value="/jydz"/>/editHttk?mobbm='+ id.id;
	}else{
	var mobbm = id.item(1).cells.item(1).innerHTML;
		window.location.href='<s:url value="/jydz"/>/editHttk?mobbm='+ mobbm;
	} */
	window.location.href='<s:url value="/hwjs"/>/bianjFyd?sysid='+ id;
	}
	
	//excel
	function exportexcel(){ 
	  var formdata = $("#form1").serialize(); 
	  window.location.href("<s:url value="/hwjs"/>/excelForFyd?"+formdata);
	
	}
	
	//打开新增菜单
	function opennew(){ 
	  window.location.href='<s:url value="/hwjs"/>/directFyddbAdd',target='mainFrame';
	}

</script>  
<body>  
<div class="container">
 <div class="containerbox">
  <div class="btn-bar"> 
    <a id="xinz" href="#" class="btn" onclick= "opennew();"><img src="<s:url value="/resources"/>/img/ico_23.gif" /><span>新增</span></a> 
    <a id="shanc" href="#" class="btn" onclick="batchremove();"><img src="<s:url value="/resources"/>/img/ico_25.gif" /><span>删除</span></a>
    <a id="excel" href="#" class="btn" onclick="exportexcel();"><img src="<s:url value="/resources"/>/img/25.gif" /> <span>导出excel</span></a>
   </div>
 <div class="search mt10" id="list_search">
<form id="form1" method="post">
<table  class="search-table"  style="width:90%"  cellpadding="0" cellspacing="0" border="0"> 
        <tr>
            <td>
            	铁路计划号:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="aa" /> 
            </td>
            <td>
                                                出卖人:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="bb" /> 
            </td>            
            <td>
               	买受人 :
            </td>
            <td>
                <input type="text" class="form-textbox" style="width: 200px;" name="cc" /> 
            </td>
        </tr>
        <tr>
            <td>
                                                发货单位:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="dd" /> 
            </td>            
            <td>
               	收货单位 :
            </td>
            <td>
                <input type="text" class="form-textbox" style="width: 200px;" name="ee" /> 
            </td>
            <td>
            	发站（局）:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="ff" /> 
            </td>
         </tr>
         <tr>
            <td>
                                                到站（局）:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="gg" />
            </td>
            <td>
                                                品名:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 200px;" name="ii" /> 
            </td>            
            <td>
               	发运吨数:
            </td>
            <td>
               <input type="text" class="form-textbox" style="width: 93px;" name="jj" /> - <input type="text" class="form-textbox" style="width: 93px;" name="kk" /> 
            </td>
         </tr>
         <tr>
            <td>
            	发运车数:
            </td>
            <td>
            	<input type="text" class="form-textbox" style="width: 93px;" name="ll" /> - <input type="text" class="form-textbox" style="width: 93px;" name="mm" /> 
            </td>
            <td>
            	发运日期:
            </td>
            <td>
            	<input id="datepicker" type="text" class="form-textbox" style="width: 93px;" name="nn" /> - <input id="datepicker1" type="text" class="form-textbox" style="width: 93px;" name="oo" />
            </td>
        </tr>
        <tr>
              <td>
                  <input id="chax" type="button" class="form-button-query form-button"  value="查询" onclick="search();"/>
                  <input id="chongz" type="reset" class="form-button-reset form-button" value="重置" />
             </td>
        </tr>
  </table>
  </form>
    </div>
    <table id="myTab" class="scroll" cellpadding="0" cellspacing="0"></table>  
   <div id="pager" class="scroll"></div>  
   <div id="message" class="scroll"></div>
   </div>
</div> 
<div id="dialog-confirm" title="是否删除发运单？"></div>
</body>
</html>
